package com.example.airobotinterviewrecord.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.airobotinterviewrecord.entity.InterviewRecover;
import com.example.airobotinterviewrecord.mapper.InterviewRecoverMapper;
import com.example.airobotinterviewrecord.service.IInterviewRecoverService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 面试人回复表 服务实现类
 * </p>
 *
 * @author author
 * @since 2025-04-08
 */
@Service
public class InterviewRecoverServiceImpl extends ServiceImpl<InterviewRecoverMapper, InterviewRecover> implements IInterviewRecoverService {

    @Override
    public Page<InterviewRecover> pageList(Integer pageNum, Integer pageSize,
                                           Integer candidateId, Integer questionId) {
        Page<InterviewRecover> page = new Page<>(pageNum, pageSize);
        LambdaQueryWrapper<InterviewRecover> wrapper = new LambdaQueryWrapper<>();

        if (candidateId != null) {
            wrapper.eq(InterviewRecover::getCandidateId, candidateId);
        }
        if (questionId != null) {
            wrapper.eq(InterviewRecover::getQuestionId, questionId);
        }
        wrapper.orderByDesc(InterviewRecover::getUpdatedAt);

        return baseMapper.selectPage(page, wrapper);
    }
}